'use client'; import { use, useEffect, useState, Suspense } from 'react'; import { useSearchParams, useRouter } from 'next/navigation'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { CheckCircle, ArrowRight, Home } from 'lucide-react'; import { useTranslations } from 'next-intl'; import { toast } from '@/hooks/use-toast'; interface PaymentSuccessPageProps { params: Promise<{ locale: string; }>; } function PaymentSuccessContent({ locale }: { locale: string }) { const searchParams = useSearchParams(); const router = useRouter(); const [isLoading, setIsLoading] = useState(true); const [sessionData, setSessionData] = useState(null); const t = useTranslations('payment.success'); useEffect(() => { const sessionId = searchParams.get('session_id'); if (!sessionId) { router.push(`/${locale}/`); return; } // 验证支付会话 const verifySession = async () => { try { const response = await fetch(`/api/verify-payment?session_id=${sessionId}`); const data = await response.json(); if (response.ok) { setSessionData(data); } else { console.error('Payment verification failed:', data.error); toast({ title: 'Payment Verification Error', description: data.error || 'Payment verification failed', variant: 'destructive' }); router.push(`/${locale}/payment/failed`); } } catch (error) { console.error('Error verifying payment:', error); toast({ title: 'Payment Verification Error', description: 'An error occurred while verifying payment', variant: 'destructive' }); router.push(`/${locale}/payment/failed`); } finally { setIsLoading(false); } }; verifySession(); }, [searchParams, router, locale, toast]); if (isLoading) { return (

{t('processing')}

{t('processingDesc')}

); } return (
{t('title')}

{t('subtitle')}

{t('subscriptionDetails')}

{t('subscriptionPlan')}: {t('proVersion')}
{t('monthlyCredits')}: {t('credits800')}
{t('subscriptionFee')}: {t('pricePerMonth')}
{t('status')}: {t('activated')}

{t('thankYou')}

{t('autoRenewal')}

); } export default function PaymentSuccessPage({ params }: PaymentSuccessPageProps) { const { locale } = use(params); return (

Loading...

}>
); }